<template>
  <p>line-hight设置文本居中</p>
  <div style="display: flex;">
    <div class="area">
      <span>文本没居中</span>
    </div>
    <div class="area">
      <span class="juzhong">文本居中了</span>
    </div>
  </div>

  <p>text-align：块级元素设置，影响其下的行内元素或行内块元素中文本的水平对齐方式。</p>
  <div>
    <div class="area ta">
      <span>行内元素居中</span>
    </div>
    <div class="area ta">
      <div class="inblock">
        行内块居中
      </div>
    </div>
    <div class="area ta">
      <div class="inblock" style="display: inline-block;">
        行内块转行内元素居中
      </div>
    </div>
  </div>

  <p>margin：auto 用于块级元素居中</p>
  <div style="height: 60px;">
    <div class="center-div pos-r">
      <div class="center-div1">
        块级元素水平居中
      </div>
      <div class="center-div2">
        块级元素垂直居中
      </div>
    </div>
  </div>

  <p>position+transform 定位居中</p>
  <div style="height: 40px;">
    <div class="center-div pos-r">
      <div class="center-div3">
        定位居中
      </div>
    </div>
  </div>

  <p>vertical-align 居中</p>
  <div class="center-div">
    <div class="va">
      参考元素
    </div>
    <span style="vertical-align: middle;">居中</span>
  </div>

</template>
  
<style scoped>
.area {
  display: inline-block;
  width: 200px;
  height: 60px;
  background-color: #30a46c;
  margin: 10px;
}

.juzhong {
  line-height: 60px;
}

.ta {
  text-align: center;
}

.inblock {
  background-color: brown;
  width: 100px;
}

.pos-r {
  position: relative;
}

.center-div {
  width: 100%;
  height: 60px;
  background-color: #30a46c;
}
.center-div1 {
  height: 28px;
  width: 150px;
  margin: 0 auto;
  background-color: brown;
}
.center-div2 {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  height: 28px;
  width: 150px;
  margin: auto 0;
  background-color: brown;
}
.center-div3 {
  position: absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  background-color: brown;
}

.va {
  display: inline-block;
  vertical-align: middle;
  background-color: brown;
  width: 100px;
  height: 40px;
}
</style>
